
#ifndef __BSP_GPIO_H_
#define __BSP_GPIO_H_

#include "apm32f0xx_gpio.h"
#include "apm32f0xx_rcm.h"
#include "apm32f0xx.h"
#include "mystruct.h"


//KEY
#define KEY_BT_PIN               GPIO_PIN_12
#define KEY_BT_GPIO_PORT         GPIOA
#define KEY_BT_GPIO_CLK          RCM_AHB_PERIPH_GPIOA

//PRODUCTION_TEST
#define PRODT_TEST_PIN               GPIO_PIN_7
#define PRODT_TEST_GPIO_PORT         GPIOF
#define PRODT_TEST_GPIO_CLK          RCM_AHB_PERIPH_GPIOF

//USB_DET
#define USB_DET_PIN               GPIO_PIN_3
#define USB_DET_GPIO_PORT         GPIOA
#define USB_DET_GPIO_CLK          RCM_AHB_PERIPH_GPIOA



 #define BAT1_nCE_PIN               GPIO_PIN_0
 #define BAT1_nCE_GPIO_PORT         GPIOC
 #define BAT1_nCE_GPIO_CLK          RCM_AHB_PERIPH_GPIOC

 #define BAT2_nCE_PIN               GPIO_PIN_1
 #define BAT2_nCE_GPIO_PORT         GPIOC
 #define BAT2_nCE_GPIO_CLK          RCM_AHB_PERIPH_GPIOC

 #define BAT3_nCE_PIN               GPIO_PIN_2
 #define BAT3_nCE_GPIO_PORT         GPIOC
 #define BAT3_nCE_GPIO_CLK          RCM_AHB_PERIPH_GPIOC

 #define BAT4_nCE_PIN               GPIO_PIN_3
 #define BAT4_nCE_GPIO_PORT         GPIOC
 #define BAT4_nCE_GPIO_CLK          RCM_AHB_PERIPH_GPIOC

 #define BAT5_nCE_PIN               GPIO_PIN_6
 #define BAT5_nCE_GPIO_PORT         GPIOC
 #define BAT5_nCE_GPIO_CLK          RCM_AHB_PERIPH_GPIOC

 #define BAT6_nCE_PIN               GPIO_PIN_7
 #define BAT6_nCE_GPIO_PORT         GPIOC
 #define BAT6_nCE_GPIO_CLK          RCM_AHB_PERIPH_GPIOC

 #define BAT7_nCE_PIN               GPIO_PIN_8
 #define BAT7_nCE_GPIO_PORT         GPIOC
 #define BAT7_nCE_GPIO_CLK          RCM_AHB_PERIPH_GPIOC

 #define BAT8_nCE_PIN               GPIO_PIN_9
 #define BAT8_nCE_GPIO_PORT         GPIOC
 #define BAT8_nCE_GPIO_CLK          RCM_AHB_PERIPH_GPIOC



#define SELECT_A1_PIN          GPIO_PIN_13
#define SELECT_A1_PORT         GPIOC
#define SELECT_A1_CLK          RCM_AHB_PERIPH_GPIOC

#define SELECT_B1_PIN          GPIO_PIN_14
#define SELECT_B1_PORT         GPIOC
#define SELECT_B1_CLK          RCM_AHB_PERIPH_GPIOC

#define SELECT_A2_PIN          GPIO_PIN_7
#define SELECT_A2_PORT         GPIOB
#define SELECT_A2_CLK          RCM_AHB_PERIPH_GPIOB

#define SELECT_B2_PIN          GPIO_PIN_6
#define SELECT_B2_PORT         GPIOB
#define SELECT_B2_CLK          RCM_AHB_PERIPH_GPIOB

#define BAT1_STAT_PIN               GPIO_PIN_12
#define BAT1_STAT_GPIO_PORT         GPIOB
#define BAT1_STAT_GPIO_CLK          RCM_AHB_PERIPH_GPIOB

#define BAT2_STAT_PIN               GPIO_PIN_13
#define BAT2_STAT_GPIO_PORT         GPIOB
#define BAT2_STAT_GPIO_CLK          RCM_AHB_PERIPH_GPIOB

#define BAT3_STAT_PIN               GPIO_PIN_14
#define BAT3_STAT_GPIO_PORT         GPIOB
#define BAT3_STAT_GPIO_CLK          RCM_AHB_PERIPH_GPIOB

#define BAT4_STAT_PIN               GPIO_PIN_15
#define BAT4_STAT_GPIO_PORT         GPIOB
#define BAT4_STAT_GPIO_CLK          RCM_AHB_PERIPH_GPIOB

#define BAT5_STAT_PIN               GPIO_PIN_8  
#define BAT5_STAT_GPIO_PORT         GPIOA
#define BAT5_STAT_GPIO_CLK          RCM_AHB_PERIPH_GPIOA

#define BAT6_STAT_PIN               GPIO_PIN_9
#define BAT6_STAT_GPIO_PORT         GPIOA
#define BAT6_STAT_GPIO_CLK          RCM_AHB_PERIPH_GPIOA

#define BAT7_STAT_PIN               GPIO_PIN_10
#define BAT7_STAT_GPIO_PORT         GPIOA
#define BAT7_STAT_GPIO_CLK          RCM_AHB_PERIPH_GPIOA

#define BAT8_STAT_PIN               GPIO_PIN_11
#define BAT8_STAT_GPIO_PORT         GPIOA
#define BAT8_STAT_GPIO_CLK          RCM_AHB_PERIPH_GPIOA

#define BAT1_RESET_PIN               GPIO_PIN_7
#define BAT1_RESET_GPIO_PORT         GPIOF
#define BAT1_RESET_GPIO_CLK          RCM_AHB_PERIPH_GPIOF

#define BAT2_RESET_PIN               GPIO_PIN_5
#define BAT2_RESET_GPIO_PORT         GPIOF
#define BAT2_RESET_GPIO_CLK          RCM_AHB_PERIPH_GPIOF

#define BAT3_RESET_PIN               GPIO_PIN_5
#define BAT3_RESET_GPIO_PORT         GPIOC
#define BAT3_RESET_GPIO_CLK          RCM_AHB_PERIPH_GPIOC

#define BAT4_RESET_PIN               GPIO_PIN_6
#define BAT4_RESET_GPIO_PORT         GPIOF
#define BAT4_RESET_GPIO_CLK          RCM_AHB_PERIPH_GPIOF

#define BAT5_RESET_PIN               GPIO_PIN_10
#define BAT5_RESET_GPIO_PORT         GPIOC
#define BAT5_RESET_GPIO_CLK          RCM_AHB_PERIPH_GPIOC

#define BAT6_RESET_PIN               GPIO_PIN_11
#define BAT6_RESET_GPIO_PORT         GPIOC
#define BAT6_RESET_GPIO_CLK          RCM_AHB_PERIPH_GPIOC

#define BAT7_RESET_PIN               GPIO_PIN_12
#define BAT7_RESET_GPIO_PORT         GPIOC
#define BAT7_RESET_GPIO_CLK          RCM_AHB_PERIPH_GPIOC

#define BAT8_RESET_PIN               GPIO_PIN_2
#define BAT8_RESET_GPIO_PORT         GPIOD
#define BAT9_RESET_GPIO_CLK          RCM_AHB_PERIPH_GPIOD







void I2C_Channel_select_IO_Int(void);


void GPIO_Init(void);

void LED_SetColour(nLEDType led, sLEDType state);
void Set_Sgm415xx_nCE(uint8_t io,uint8_t en);
void Set_Sgm415xx_nQON(uint8_t io,uint8_t en);

#endif




